<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script type="text/javascript">
    function checkForm(){
      var name = document.getElementById("name").value;
      if(name.length<6){
        document.getElementById("msg").innerHTML="用户名太短";
        return false;
      }
      return true;
    }
  </script>
</head>
<body>
  <form action="http://www.baidu.com" onsubmit="return checkForm()">
    <table align="center">
      <tr><td>账号</td><td><input type="text" id="name"/></td><td width="200"><span id="msg"></span></td></tr>
      <tr><td>密码</td><td><input type="password"/></td><td><span id="msg"></span></td></tr>
      <tr><td colspan="3"><input type="submit"/></td></tr>
    </table>
  </form>
</body>
</html>